﻿using System;
using System.Windows;
using SmartSpace.Data;

namespace SsTool.Metadata.Windows
{
    /// <summary>
    /// Interaction logic for PropertyTypeMetadataWindow.xaml
    /// </summary>
    public partial class PropertyTypeMetadataWindow : Window
    {
        public TypeMetadata PropertyTypeMetadata { get; private set; }

        public PropertyTypeMetadataWindow()
        {
            InitializeComponent();

            PropertyTypeMetadata = new TypeMetadata();
            PropertyTypeMetadata.Id = Guid.NewGuid();

            this.DataContext = PropertyTypeMetadata;
        }

        public PropertyTypeMetadataWindow(TypeMetadata type)
        {
            InitializeComponent();

            PropertyTypeMetadata = type;

            this.DataContext = PropertyTypeMetadata;
        }

        private void _ctlBtnCreate_Click(object sender, RoutedEventArgs e)
        {
            IDataService service = App.Get<IDataService>();
            if (service.StoreType(PropertyTypeMetadata) == true)
            {
                DialogResult = true;
            }
        }

        private void _ctlBtnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
